<?php $this->renderPartial('_numbering_tabs', array('type' => $type)); ?>
<div class="grid_10">
	<?php
	$form = $this->beginWidget('PsActiveForm', array(
		'id' => 'admin-accounting-numbering-form',
		'enableAjaxValidation' => FALSE
	));
	?>
    <div class="admin-accounting-numbering form">
		<div class="section numbering">
			<div class="block">
				<h2><?php echo $title; ?>
					<h4>Numbering method</h4>
					<table class="form-table">
						<tr>
							<td class="valign-top" width="20">
								<?php
								echo $form->radioButton($documentNumbering, 'numbering_method', array(
									'id' => 'DocumentNumberingMethod_default',
									'class' => 'numbering-method numbering-method-default',
									'value' => 'default',
									'uncheckValue' => null,
									'autocomplete' => 'off'
								));
								?>
							</td>
							<td class="valign-top">
								<?php echo CHtml::label('Increment previous number (Default)', 'DocumentNumberingMethod_default'); ?>
							</td>
						</tr>
						<tr>
							<td class="valign-top">
								<?php
								echo $form->radioButton($documentNumbering, 'numbering_method', array(
									'id' => 'DocumentNumberingMethod_yyyymm',
									'class' => 'numbering-method numbering-method-yyyymm',
									'value' => 'yyyymm',
									'uncheckValue' => null,
									'autocomplete' => 'off'
								));
								?>
							</td>
							<td class="valign-top">
								<?php echo CHtml::label('Year, month and number', 'DocumentNumberingMethod_yyyymm'); ?>
							</td>
						</tr>
						<tr>
							<td class="valign-top">
								<?php
								echo $form->radioButton($documentNumbering, 'numbering_method', array(
									'id' => 'DocumentNumberingMethod_yyyy',
									'class' => 'numbering-method numbering-method-yyyy',
									'value' => 'yyyy',
									'uncheckValue' => null,
									'autocomplete' => 'off'
								));
								?>
							</td>
							<td class="valign-top">
								<?php echo CHtml::label('Year and number', 'DocumentNumberingMethod_yyyy'); ?>
							</td>
						</tr>
						<tr>
							<td class="valign-top">
								<?php
								echo $form->radioButton($documentNumbering, 'numbering_method', array(
									'id' => 'DocumentNumberingMethod_custom',
									'class' => 'numbering-method numbering-method-custom',
									'value' => 'custom',
									'uncheckValue' => null,
									'autocomplete' => 'off'
								));
								?>
							</td>
							<td class="valign-top">
								<?php echo CHtml::label('Custom numbering', 'DocumentNumberingMethod_custom'); ?><br/>
								<?php echo $form->textField($documentNumbering, 'numbering_format', array('class' => 'numbering-format code', 'size' => 45)); ?>
								<?php echo $form->error($documentNumbering, 'numbering_format'); ?>
								<br/>
								e.g. <span class="numbering-format-example code"><?php echo $documentNumbering->getExample(); ?></span>
							</td>
						</tr>
					</table>
					<h4>Other Settings</h4>
					<table class="form-table other-settings">
						<tr>
							<td class="valign-middle" width="20">
								<?php
								echo $form->checkBox($documentNumbering, 'zerofill', array('id' => 'DocumentNumberingZerofill', 'class' => 'numbering-zerofill valign-middle', 'uncheckValue' => 0,
									'autocomplete' => 'off'));
								?>
							</td>
							<td>
								<?php echo CHtml::label('Pad auto-number with', 'DocumentNumberingZerofill'); ?>
							</td>
							<td>
								<?php
								$this->widget('common.widgets.PsAutoNumeric.PsAutoNumeric', array(
									'model' => $documentNumbering,
									'attribute' => 'zerofill_length',
									'htmlOptions' => array(
										'id' => 'DocumentNumbering_zerofill_length',
										'size' => 4,
										'class' => 'numbering-zerofill-length align-right',
										'disabled' => $documentNumbering->zerofill == 0,
									),
									'options' => array(
										'aSep' => '',
										'vMin' => 0,
										'vMax' => '11'
									)
								));
								?>
								&nbsp; leading zeroes
							</td>
						</tr>
						<tr>
							<td class="valign-middle" width="20">
								<?php
								echo $form->checkBox($documentNumbering, 'restart_numbering', array('id' => 'DocumentNumberingRestart', 'class' => 'restart-numbering valign-middle', 'uncheckValue' => 0,
									'autocomplete' => 'off'));
								?>
							</td>
							<td width="150">
								<?php echo CHtml::label('Restart Numbering', 'DocumentNumberingRestart'); ?>
							</td>
							<td>							
								<?php
								echo $form->dropDownList($documentNumbering, 'restart_numbering_type', DocumentNumbering::getRestartNumberingListData(), array(
									'class' => 'restart-numbering-type',
									'disabled' => $documentNumbering->restart_numbering == 0,
									'autocomplete' => 'off'
										)
								);
								?>
							</td>
						</tr>
						<tr>
							<td class="valign-middle" width="20">
								<?php
								echo $form->checkBox($documentNumbering, 'start_from', array('id' => 'DocumentNumberingStartFrom', 'class' => 'start-from valign-middle', 'uncheckValue' => 0,
									'autocomplete' => 'off'));
								?>
							</td>
							<td width="150">
								<?php echo CHtml::label('Start Numbering From', 'DocumentNumberingStartFrom'); ?>
							</td>
							<td>
								<?php
								$this->widget('common.widgets.PsAutoNumeric.PsAutoNumeric', array(
									'model' => $documentNumbering,
									'attribute' => 'start_from_number',
									'htmlOptions' => array(
										'id' => 'DocumentNumbering_start_from_number',
										'size' => '9',
										'class' => 'align-right',
										'disabled' => $documentNumbering->start_from == 0,
									),
									'options' => array(
										'aSep' => '',
										'vMin' => 0,
										'vMax' => ($documentNumbering->zerofill ? str_repeat('9', $documentNumbering->zerofill_length) : '99999999999')
									)
								));
								?>
							</td>
						</tr>
					</table>
			</div>
		</div>
		<div class="form-buttons">
			<p><?php echo CHtml::submitButton('Save Changes', array('class' => 'green link-button no-margin')); ?></p>
		</div>
    </div>
	<?php $this->endWidget(); ?>
</div>
<div class="grid_6">
	<div class="section highlighted">
		<div class="block">
			<h2>Help</h2>
			<p>By default new Invoices, Receipts and Payment Vouchers are numbered by incrementing the right-most number of the previously created document.</p>
			<p>You can change how subsequent documents are numbered by changing the options to the left.</p>
			<h4>Custom numbering tags</h4>
			<?php foreach ($documentNumbering->tokens() as $tokenKey => $tokenDescription): ?>
				<dl>
					<dt>%<?php echo $tokenKey; ?>%</dt>
					<dd><?php echo $tokenDescription; ?></dd>
				</dl>
			<?php endforeach; ?>
		</div>
	</div>
</div>